"""
功能描述：
1.模拟web浏览器，去执行ui自动化脚本
2.模拟发送http协议接口请求
"""

from selenium import webdriver


class Driver:
    driver = None

    @classmethod
    def get_driver(cls, browser='chrome'):
        if cls.driver == None:
            if browser == 'chrome':
                cls.driver = webdriver.Chrome()
            elif browser == 'ie':
                cls.driver = webdriver.Ie(executable_path=r'')
            else:
                cls.driver = webdriver.Firefox()
            cls.driver.maximize_window()
            # cls.driver.set_page_load_timeout(10)  # 页面加载的超时时间
            # cls.driver.set_script_timeout(10)  # 执行JavaScript脚本的超时时间
            # cls.driver.implicitly_wait(10)  # 如果元素没有找到，尝试继续等待的时间

        return cls.driver

    @classmethod
    def quit_driver(cls):
        cls.driver.close()
